require.config({
                baseUrl:"../",
	paths:{
		bsl:'bsl',

	}
});
require(['bsl'],function(bsl){
	document.addEventListener('deviceready', onDeviceready, false);
        function onDeviceready(){
        alert("star");
        
        function openDatabase(){
        var db = bsl.storage.openDatabase("database", "1.0", "cordova demo", 2000000);
        db.transaction(populateDB, errorCB, successCB);
        }
        function populateDB(tx) {
        var name=document.getElementById("id").value;
        var namedata=document.getElementById("data").value;
        tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
        
        tx.executeSql('INSERT INTO DEMO (id, data) VALUES ('+ name +', '+ namedata+')');
        
        }
        function errorCB(tx, err) {
        alert("Error processing SQL: "+err);
        }
        function successCB() {
        var db = bsl.storage.openDatabase("database", "1.0", "cordova demo", 2000000);
        db.transaction(queryDB, errorCB);
        }
        function queryDB(tx) {
        tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
        }
        function querySuccess(tx, results) {
        var len = results.rows.length;
        alert("DEMO table: " + len + " rows found.");
        for (var i=0; i<len; i++){
        alert("Row = " + i + " ID = " + results.rows.item(i).id + " Data =  " + results.rows.item(i).data);
        }
        }
        
        document.getElementById("openDatabase").addEventListener("click",openDatabase,false);
        document.getElementById("show").addEventListener("click",successCB,false);
        }
});